Component({
  options: {
    addGlobalClass: true,
  },
  properties: {
    items: {
      type: Object,
      value: [],
    },
    invalidItems: {
      type: Object,
      value: []
    },
  },
  data: {
    dialogShow: false,
    allNum: 1,
    contentHeight: 300,
    showItems: [],
    parentItems:[]
  },
  observers: {
    'items, invalidItems': function (items, invalidItems) {
      if (!items && !invalidItems) {
        return;
      }
      let allItems = [];
      allItems = allItems.concat(items);
      allItems = allItems.concat(invalidItems);

      let allNum = 0;
      for (let i = 0; i < allItems.length; i++) {
        allNum += allItems[i].num
      }
      this.setData({allNum: allNum, allItems})
     const parentItems = allItems.filter((item,index)=>{
        if(item.parentGoodsId===0) return item;
      })
      this.setData({parentItems})
    }
  },
  methods: {
    handleClose() {
      this.setData({dialogShow:false})
    },
    handleDialogShow() {
      this.setData({dialogShow:true})
    },
    handleContentHeight(e) {
      this.setData({contentHeight: e.detail})
    }
  }
});
